<?php

namespace app\admin\model;

use think\Model;


class ExamItem extends Model
{

    

    

    // 表名
    protected $name = 'exam_item';
    
    // 自动写入时间戳字段
    protected $autoWriteTimestamp = false;

    // 定义时间戳字段名
    protected $createTime = false;
    protected $updateTime = false;
    protected $deleteTime = false;

    // 追加属性
    protected $append = [
        // 追加属性
        'rightlist_text'
    ];

    public function getRightlistList()
    {
        return ['A' => __('A'), 'B' => __('B'), 'C' => __('C'), 'D' => __('D'), 'E' => __('E'), 'F' => __('F')];
    }
    public function getRightList()
    {
        return ['A' => __('A'), 'B' => __('B'), 'C' => __('C'), 'D' => __('D'), 'E' => __('E'), 'F' => __('F')];
    }

    public function getRightlistTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['right']) ? $data['right'] : '');
        $list = $this->getRightList();
        return isset($list[$value]) ? $list[$value] : '';
    }
    public function getRightTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['rightlist']) ? $data['rightlist'] : '');
        $list = $this->getRightlistList();
        return isset($list[$value]) ? $list[$value] : '';
    }

    public function exam()
    {
        return $this->belongsTo('Exam', 'exam_id', 'id', [], 'LEFT')->setEagerlyType(0);
    }
    protected function setRightlistAttr($value)
    {
        return is_array($value) ? implode(',', $value) : $value;
    }
}
